<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs;

    protected $state_list = [];

    protected function success($data = [], $msg = ''){
        return response()->json([
            'code' => 200,
            'message' => '',
            'data' => $data
        ]); 
    }

    protected function error($msg = '', $code = 500){
        return response()->json([
            'code' => $code,
            'message' => $msg,
            'data' => []
        ]); 
    }

    protected function showError($msg = ''){
        return response()->json([
            'code' => 200,
            'message' => '',
            'data' => [
                'error' => true,
                'message' => $msg,
            ]
        ]); 
    }

    public function state_list(){
        $res = [];
        foreach($this->state_list as $k => $v){
            $res[] = [
                'value' => $k,
                'label' => $v
            ];
        }
        return $this->success($res);
    }

}
